import { Tooltip } from 'antd';
import { Fragment } from 'react';
import {
  // EyeOutlined,
  EditOutlined,
  FileExcelOutlined,
  UploadOutlined,
  FileExclamationOutlined,
  FileTextOutlined,
  DeleteOutlined,
  RollbackOutlined,
  DownloadOutlined,
  AuditOutlined,
} from '@ant-design/icons';
import {
  getColorTextLoadMap,
  getColorTextLoadMapDom,
  getFileNameByPath,
  getTenantID,
  getUserID,
  newGetFileNameNotType,
  removeDateHmsStr,
  renderTableText,
  renderTableTextNotColor,
  tableSorter,
  tooltipLength,
  priceFormat,
  getPosIDs,
  getPosName,
} from '@/utils';
import pageStyles from '@/common/pageLayout.less';
import MyIcon from '@/components/MyIcon';
import { ContractManageAPI } from '../common/type';
import { ILoadMapTypeAll } from '@/common';
import { ManageCommonAPI } from '@/pages/type';
import { tableMoreBtnConfig } from '@/utils/myutilConfig';
import Cls from 'classnames';
import moment from 'moment';

// 操作按钮
const Operation = (curRes: Record<string, any>, clickFnc: ContractManageAPI.IOperationClick, record: Record<string, any>) => {
  /** 科研助理可编辑判断 */
  const KYZL_PAND = (record) => {
    return (record?.createPositionID == getPosIDs() && record?.ownerID == getUserID()) || getPosName() == '科研助理';
    // return record?.createPositionID == getPosIDs() && record?.ownerID == getUserID();
  };

  /** 更多按钮配置 */
  const otherBtnConfig: ManageCommonAPI.TableMoreBtnConfigApi[] = [
    {
      icon: <EditOutlined />,
      btnName: '编辑',
      clickFnc: clickFnc,
      clickType: 'onEdit',
      isVisible:
        curRes?.['/contractController/edit'] &&
        record?.id &&
        KYZL_PAND(record) &&
        (record?.state == `${getTenantID()}${ILoadMapTypeAll.CONTRACT_STATE}1000` ||
          (record?.state == `${getTenantID()}${ILoadMapTypeAll.CONTRACT_STATE}1001`
            ? record?.checkState == `${getTenantID()}${ILoadMapTypeAll.ALLFLOW_CHECKRESULT}1001`
            : false)),
    },
    {
      icon: <AuditOutlined />,
      btnName: '签章',
      clickFnc: clickFnc,
      clickType: 'onStamp',
      isVisible: curRes?.['/contractController/seal'] && record?.id && record?.state == `${getTenantID()}${ILoadMapTypeAll.CONTRACT_STATE}1002`,
    },
    {
      icon: <AuditOutlined />,
      btnName: '归档',
      clickFnc: clickFnc,
      clickType: 'onfinish',
      isVisible:
        curRes?.['/contractController/finish'] &&
        record?.id &&
        record?.state == `${getTenantID()}${ILoadMapTypeAll.CONTRACT_STATE}1004` &&
        record.ownerID == `${getUserID()}` &&
        record?.createPositionID == getPosIDs() &&
        !record.pID &&
        isOverFinishTime(record),
    },
    {
      icon: <FileTextOutlined />,
      btnName: '打印',
      clickFnc: clickFnc,
      clickType: 'onPrint',
      isVisible:
        // curRes?.['/contractController/seal'] &&
        (record?.scanURL || record?.sealURL) &&
        record?.id &&
        KYZL_PAND(record) &&
        (record?.state == `${getTenantID()}${ILoadMapTypeAll.CONTRACT_STATE}1003` || record?.state == `${getTenantID()}${ILoadMapTypeAll.CONTRACT_STATE}1004`),
    },
    {
      icon: <UploadOutlined />,
      btnName: '扫描件',
      clickFnc: clickFnc,
      clickType: 'onSignBtn',
      isVisible:
        curRes?.['/contractController/sign'] &&
        record?.id &&
        record?.createPositionID == getPosIDs() &&
        record?.ownerID == getUserID() &&
        record?.state == `${getTenantID()}${ILoadMapTypeAll.CONTRACT_STATE}1003` &&
        (record?.checkState == `${getTenantID()}${ILoadMapTypeAll.ALLFLOW_CHECKRESULT}1002` ||
          record?.checkState == `${getTenantID()}${ILoadMapTypeAll.ALLFLOW_CHECKRESULT}1003`),
    },
    {
      icon: <FileExclamationOutlined style={{ color: 'red' }} />,
      btnName: <span style={{ color: 'red' }}>变更</span>,
      clickFnc: clickFnc,
      clickType: 'onModify',
      isVisible:
        curRes?.['/contractController/modifyRouter'] &&
        record?.id &&
        !record?.pID &&
        record?.state == `${getTenantID()}${ILoadMapTypeAll.CONTRACT_STATE}1004` &&
        (record?.relateNum == 0 ? true : record?.lockFlag == 1) &&
        KYZL_PAND(record),
    },
    {
      icon: <FileExcelOutlined style={{ color: 'red' }} />,
      btnName: <span style={{ color: 'red' }}>解除</span>,
      clickFnc: clickFnc,
      clickType: 'onBreak',
      isVisible:
        curRes?.['/contractController/breakRouter'] &&
        record?.id &&
        !record?.pID &&
        record?.state == `${getTenantID()}${ILoadMapTypeAll.CONTRACT_STATE}1004` &&
        (record?.relateNum == 0 ? true : record?.lockFlag == 1) &&
        KYZL_PAND(record),
    },
    {
      icon: <DeleteOutlined style={{ color: 'red' }} />,
      btnName: <span style={{ color: 'red' }}>删除</span>,
      clickFnc: clickFnc,
      clickType: 'onDelete',
      isVisible:
        curRes['/contractController/delete'] &&
        KYZL_PAND(record) &&
        record?.id &&
        (record?.state == `${getTenantID()}${ILoadMapTypeAll.CONTRACT_STATE}1000` ||
          (record?.state == `${getTenantID()}${ILoadMapTypeAll.CONTRACT_STATE}1002` && isOverTime(record))),
    },
    {
      icon: <RollbackOutlined style={{ color: 'red' }} />,
      btnName: <span style={{ color: 'red' }}>撤销</span>,
      clickFnc: clickFnc,
      clickType: 'onRevoke',
      isVisible:
        curRes['/contractController/invalid'] &&
        record?.id &&
        record?.ownerID == getUserID() &&
        record?.createPositionID == getPosIDs() &&
        record?.state == `${getTenantID()}${ILoadMapTypeAll.CONTRACT_STATE}1001`,
    },
    // {
    //   icon: <StopOutlined style={{ color: 'red' }} />,
    //   btnName: <span style={{ color: 'red' }}>作废</span>,
    //   clickFnc: clickFnc,
    //   clickType: 'onCancel',
    //   isVisible:
    //     curRes['/contractController/cancel'] &&
    //     record?.id &&
    //     record?.ownerID == getUserID() &&
    //     (record?.state == `${getTenantID()}${ILoadMapTypeAll.CONTRACT_STATE}1002` ||
    //       record?.state == `${getTenantID()}${ILoadMapTypeAll.CONTRACT_STATE}1003` ||
    //       (!record?.pID ? false : record?.state == `${getTenantID()}${ILoadMapTypeAll.CONTRACT_STATE}1004`)) &&
    //     (record?.relateNum == 0 ? true : record?.lockFlag == 1),
    // },
    {
      icon: <DownloadOutlined />,
      btnName: '下载',
      clickFnc: clickFnc,
      clickType: 'onDownload',
      isVisible: record?.id && record?.scanURL && record?.state == `${getTenantID()}${ILoadMapTypeAll.CONTRACT_STATE}1005`,
    },
  ];

  return tableMoreBtnConfig(otherBtnConfig, record);
};

const isOverTime = (record) => {
  const isOver =
    record?.state == `${getTenantID()}${ILoadMapTypeAll.CONTRACT_STATE}1002` && moment().isAfter(record.bidTime) && moment().diff(record.bidTime, 'days') >= 30;
  return isOver;
};

//根据合同截止时间，判断是否要进行归档，且合同名称用红色标识
const isOverFinishTime = (record) => {
  const isOver = record?.state == `${getTenantID()}${ILoadMapTypeAll.CONTRACT_STATE}1004` && moment().isAfter(record.realFinishTime);
  return isOver;
};

const getTableColumns = (
  curRes: Record<string, any>,
  clickFnc: ContractManageAPI.IOperationClick,
  styleName: string,
  pageParams: Record<string, any> | null,
) => {
  let tableConfig = [
    {
      title: '申请部门/单位',
      dataIndex: 'ownDepartmentName',
      key: 'ownDepartmentName',
      width: 150,
      visible: true,
      fixed: 'left',
      unDrag: true,
      sorter: (a: any, b: any) => tableSorter(a, b, 'ownDepartmentID'),
      // render: (text: string) => renderTableText(text, true),
      render: (text: number | any, record: Record<string, any>) => {
        return (
          <Tooltip title={tooltipLength(text, 50)}>
            <span className={pageStyles['over-flow-hidden']} style={{ width: '90%', display: 'inline-block' }}>
              {record?.pID && pageParams?.manageTreeTable && <MyIcon type="icon-dian" isTheme={false} />}
              {text || '--'}
            </span>
          </Tooltip>
        );
      },
    },
    {
      title: '合同类型',
      dataIndex: 'businessTypeName',
      key: 'businessTypeName',
      width: 190,
      visible: true,
      fixed: 'left',
      unDrag: true,
      sorter: (a: any, b: any) => tableSorter(a, b, 'businessTypeName'),
      render: (text: string) => renderTableText(text, true),
    },
    {
      title: '合同名称',
      dataIndex: 'contractName',
      key: 'contractName',
      width: 230,
      visible: true,
      fixed: 'left',
      unDrag: true,
      render: (text: number | any, record: Record<string, any>) => {
        const relateNum: number = record?.relateNum ? record?.relateNum : 0;
        /* isOverTime是否超过30天 超出则显示红色 不超出显示蓝色*/
        return (
          <div className={`${styleName}titleBox`}>
            {text ? (
              <a
                onClick={() => {
                  clickFnc?.onView(record);
                }}
                style={{ color: '100%' }}
              >
                <Tooltip title={tooltipLength(text, 50)}>
                  <span
                    className={Cls(
                      pageStyles['over-flow-hidden'],
                      `${styleName}titleBox-spanText`,
                      `${
                        isOverTime(record) || (isOverFinishTime(record) && record.state == `${getTenantID()}${ILoadMapTypeAll.CONTRACT_STATE}1004`)
                          ? `${styleName}titleBox-red`
                          : ''
                      }`,
                    )}
                  >
                    {text || '--'}
                  </span>
                </Tooltip>
              </a>
            ) : (
              <span>--</span>
            )}

            {relateNum != 0 && (
              <div className={`${styleName}titleBox-relateNumBox`}>
                <span className={`${styleName}titleBox-${relateNum > 9 ? 'countTextBeyondTen' : 'countTextWithinTen'}`}>{relateNum}</span>
              </div>
            )}
          </div>
        );
      },
    },
    {
      title: '合同编号',
      dataIndex: 'contractCode',
      key: 'contractCode',
      width: 250,
      visible: true,
      sorter: (a: any, b: any) => tableSorter(a, b, 'contractCode'),
      render: (text: string) => {
        return text || '--';
      },
    },
    {
      title: '合同金额（元）',
      dataIndex: 'sumInTax',
      key: 'sumInTax',
      width: 180,
      visible: true,
      sorter: (a: any, b: any) => tableSorter(a, b, 'sumInTax'),
      render: (text: string | null) => {
        return <span className={pageStyles['over-flow-hidden']}>{text ? `${priceFormat(text)}` : '0.00'}</span>;
      },
    },

    {
      title: '币种',
      dataIndex: 'currencyTypeName',
      key: 'currencyTypeName',
      width: 190,
      visible: true,
      sorter: (a: any, b: any) => (a?.state > b?.state ? 1 : -1),
      render: (text: string | null) => {
        const { colorText } = getColorTextLoadMap(text);
        return <span className={pageStyles['over-flow-hidden']}>{colorText ? colorText : '--'}</span>;
      },
    },
    {
      title: '合同状态',
      dataIndex: 'stateName',
      key: 'stateName',
      width: 190,
      visible: true,
      sorter: (a: any, b: any) => (a?.state > b?.state ? 1 : -1),
      render: (text: string | null) => {
        const { colorText, color } = getColorTextLoadMap(text);
        return (
          <span className={pageStyles['over-flow-hidden']}>
            {/* <MyIcon type="icon-dian" style={{ color }} /> */}
            {colorText ? colorText : '--'}
          </span>
        );
      },
    },
    {
      title: '审核状态',
      dataIndex: 'checkStateName',
      key: 'checkStateName',
      width: 130,
      visible: true,
      isShowCheckState: true,
      sorter: (a: any, b: any) => (a?.state > b?.state ? 1 : -1),
      render: (text: string | null) => {
        const { colorText } = getColorTextLoadMap(text);
        return <span className={pageStyles['over-flow-hidden']}>{colorText ? colorText : '--'}</span>;
      },
    },
    {
      title: '提醒次数',
      dataIndex: 'handleNum',
      key: 'handleNum',
      width: 120,
      visible: true,
      isHandle: true,
      sorter: (a: any, b: any) => tableSorter(a, b, 'handleNum'),
      render: (text: string, record: object) => {
        if (text) {
          return (
            <a
              onClick={() => {
                clickFnc?.onUrge(record);
              }}
            >
              {text}
            </a>
          );
        } else {
          return <span>0</span>;
        }
      },
    },
    {
      title: '提醒时间',
      dataIndex: 'handleTime',
      key: 'handleTime',
      width: 190,
      visible: true,
      isHandle: true,
      sorter: (a: any, b: any) => tableSorter(a, b, 'handleTime'),
      render: (text: string) => {
        const dateText: string = removeDateHmsStr(text);
        return <span className={pageStyles['over-flow-hidden']}>{dateText}</span>;
      },
    },
    {
      title: '提醒人',
      dataIndex: 'handlerName',
      key: 'handlerName',
      visible: true,
      width: 120,
      isHandle: true,
      sorter: (a: any, b: any) => tableSorter(a, b, 'handlerName'),
      render: (text: string) => renderTableText(text, true),
    },
    {
      title: '合同签订时间',
      dataIndex: 'realBeginTime',
      key: 'realBeginTime',
      width: 190,
      visible: true,
      sorter: (a: any, b: any) => tableSorter(a, b, 'realBeginTime'),
      render: (text: string) => {
        const dateText: string = removeDateHmsStr(text);
        return <span className={pageStyles['over-flow-hidden']}>{dateText}</span>;
      },
    },
    {
      title: '合同截止时间',
      dataIndex: 'realFinishTime',
      key: 'realFinishTime',
      width: 190,
      visible: true,
      sorter: (a: any, b: any) => tableSorter(a, b, 'realFinishTime'),
      render: (text: string) => {
        const dateText: string = removeDateHmsStr(text);
        return <span className={pageStyles['over-flow-hidden']}>{dateText}</span>;
      },
    },
    {
      title: '相对方',
      dataIndex: 'supplierName',
      key: 'supplierName',
      width: 180,
      visible: true,
      sorter: (a: any, b: any) => tableSorter(a, b, 'supplierName'),
      render: (text: string) => renderTableText(text, true),
    },
    {
      title: '合同主体',
      dataIndex: 'oppositeName',
      key: 'oppositeName',
      width: 180,
      visible: true,
      sorter: (a: any, b: any) => tableSorter(a, b, 'oppositeName'),
      render: (text: string) => renderTableText(text, true),
    },
    {
      title: '组织形式',
      dataIndex: 'procureOrgName',
      key: 'procureOrgName',
      width: 180,
      visible: true,
      sorter: (a: any, b: any) => tableSorter(a, b, 'procureOrg'),
      render: (text: string) => renderTableTextNotColor(text, true),
    },
    {
      title: '采购方式',
      dataIndex: 'procureRealName',
      key: 'procureRealName',
      width: 180,
      visible: true,
      sorter: (a: any, b: any) => tableSorter(a, b, 'procureReal'),
      render: (text: string) => renderTableTextNotColor(text, true),
    },
    {
      title: '资金来源',
      dataIndex: 'projectName',
      key: 'projectName',
      width: 180,
      visible: true,
      sorter: (a: any, b: any) => tableSorter(a, b, 'projectName'),
      render: (text: string) => renderTableText(text, true),
    },
    {
      title: '资金流向',
      dataIndex: 'capitalDir',
      key: 'capitalDir',
      width: 120,
      visible: true,
      sorter: (a: any, b: any) => tableSorter(a, b, 'capitalDir'),
      render: (text: string | null) => {
        let newText: string = '--';
        if (text == '0') {
          newText = '付款';
        } else if (text == '1') {
          newText = '收款';
        } else if (text == '2') {
          newText = '无金额';
        }
        return (
          <Tooltip title={text ? newText : ''}>
            <span className={pageStyles['over-flow-hidden']}>{newText}</span>
          </Tooltip>
        );
      },
    },
    {
      title: '支付方式',
      dataIndex: 'payStyleName',
      key: 'payStyleName',
      width: 120,
      visible: true,
      sorter: (a: any, b: any) => tableSorter(a, b, 'payStyle'),
      render: (text: string | null) => {
        const { colorText } = getColorTextLoadMap(text);
        return <span className={pageStyles['over-flow-hidden']}>{colorText ? colorText : '--'}</span>;
      },
    },
    {
      title: '是否重大（要）合同',
      dataIndex: 'majorFlag',
      key: 'majorFlag',
      width: 220,
      visible: true,
      sorter: (a: any, b: any) => tableSorter(a, b, 'majorFlag'),
      render: (text: string) => renderTableTextNotColor(text),
    },
    {
      title: '是否补录',
      dataIndex: 'recordFlag',
      key: 'recordFlag',
      width: 220,
      visible: true,
      sorter: (a: any, b: any) => tableSorter(a, b, 'recordFlag'),
      render: (text: string) => renderTableTextNotColor(text),
    },
    {
      title: '合同简介',
      dataIndex: 'contractInfo',
      key: 'contractInfo',
      width: 230,
      visible: false,
      sorter: (a: any, b: any) => tableSorter(a, b, 'contractInfo'),
      render: (text: string) => renderTableText(text, true, 200),
    },

    {
      title: '起始时间（预计）',
      dataIndex: 'preBeginTime',
      key: 'preBeginTime',
      width: 190,
      visible: false,
      sorter: (a: any, b: any) => tableSorter(a, b, 'preBeginTime'),
      render: (text: string) => {
        const dateText: string = removeDateHmsStr(text);
        return <span className={pageStyles['over-flow-hidden']}>{dateText}</span>;
      },
    },
    {
      title: '结束时间（预计）',
      dataIndex: 'preFinishTime',
      key: 'preFinishTime',
      width: 190,
      visible: false,
      sorter: (a: any, b: any) => tableSorter(a, b, 'preFinishTime'),
      render: (text: string) => {
        const dateText: string = removeDateHmsStr(text);
        return <span className={pageStyles['over-flow-hidden']}>{dateText}</span>;
      },
    },
    {
      title: '合同文本',
      dataIndex: 'contractURL',
      key: 'contractURL',
      width: 280,
      visible: true,
      render: (text: string | null, record: Record<string, any>) => {
        const fileName: string = getFileNameByPath(text);
        return (
          <>
            {text ? (
              <Tooltip title={fileName}>
                <div style={{ display: 'flex', justifyContent: 'space-between' }}>
                  <a
                    // onClick={() => {
                    //   downloadTemplate('/contractController/downloadFile', fileName, text, () => { });
                    // }}
                    onClick={() => {
                      // clickFnc?.onNtko(record, 'contractURL');
                      clickFnc?.onOpenRead(record);
                    }}
                  >
                    <MyIcon type="icon-file-text-fill" />
                    &nbsp;
                    {newGetFileNameNotType(fileName, 7)}
                  </a>
                </div>
              </Tooltip>
            ) : (
              <>--</>
            )}
          </>
        );
      },
    },
    {
      title: '合同扫描件',
      dataIndex: 'scanURL',
      key: 'scanURL',
      width: 280,
      visible: true,
      render: (text: string | null, record: Record<string, any>) => {
        const fileName: string = getFileNameByPath(text);
        return (
          <>
            {text ? (
              <Tooltip title={fileName}>
                <div style={{ display: 'flex', justifyContent: 'space-between' }}>
                  <a
                    // onClick={() => {
                    //   downloadTemplate('/contractController/downloadFile', fileName, text, () => { });
                    // }}
                    onClick={() => {
                      clickFnc?.onNtko(record, 'scanURL');
                    }}
                  >
                    <MyIcon type="icon-file-text-fill" />
                    &nbsp;
                    {newGetFileNameNotType(fileName, 7)}
                  </a>
                  {/* {(curRes?.['/contractController/readUpdate'] || curRes?.['/contractController/readOnly']) && (
                    <a
                      onClick={() => {
                        clickFnc?.onNtko(record, 'scanURL');
                      }}
                    >
                      &nbsp;
                      <EyeOutlined />
                    </a>
                  )} */}
                </div>
              </Tooltip>
            ) : (
              <>--</>
            )}
          </>
        );
      },
    },
    // {
    //   title: '合同签章文件',
    //   dataIndex: 'sealURL',
    //   key: 'sealURL',
    //   width: 280,
    //   visible: true,
    //   render: (text: string | null, record: Record<string, any>) => {
    //     const fileName: string = getFileNameByPath(text);
    //     return (
    //       <>
    //         {text ? (
    //           <Tooltip title={fileName}>
    //             <div style={{ display: 'flex', justifyContent: 'space-between' }}>
    //               <a
    //                 onClick={() => {
    //                   downloadTemplate('/contractController/downloadFile', fileName, text, () => { });
    //                 }}
    //               // onClick={() => {
    //               //   clickFnc?.onNtko(record, 'sealURL');
    //               // }}
    //               >
    //                 <MyIcon type="icon-file-text-fill" />
    //                 &nbsp;
    //                 {newGetFileNameNotType(fileName, 7)}
    //               </a>
    //               {/* {(curRes?.['/contractController/readUpdate'] || curRes?.['/contractController/readOnly']) && (
    //                 <a
    //                   onClick={() => {
    //                     clickFnc?.onNtko(record, 'sealURL');
    //                   }}
    //                 >
    //                   &nbsp;
    //                   <EyeOutlined />
    //                 </a>
    //               )} */}
    //             </div>
    //           </Tooltip>
    //         ) : (
    //           <>--</>
    //         )}
    //       </>
    //     );
    //   },
    // },
    // {
    //   title: '起草时间',
    //   dataIndex: 'createTime',
    //   key: 'createTime',
    //   visible: true,
    //   width: 150,
    //   sorter: (a: any, b: any) => (a.createTime > b.createTime ? 1 : -1),
    //   render: (text: string) => {
    //     const timeStr: string = removeDateHmsStr(text);
    //     return (
    //       <>
    //         <span className={pageStyles['over-flow-hidden']}>{timeStr}</span>
    //       </>
    //     );
    //   },
    // },
    {
      title: '提醒岗位',
      dataIndex: 'handlePositionName',
      key: 'handlePositionName',
      visible: false,
      width: 150,
      isHandle: true,
      sorter: (a: any, b: any) => tableSorter(a, b, 'handlePositionName'),
      render: (text: string) => renderTableText(text, true),
    },
    {
      title: '提醒部门',
      dataIndex: 'handleDepartmentName',
      key: 'handleDepartmentName',
      visible: false,
      width: 150,
      isHandle: true,
      sorter: (a: any, b: any) => tableSorter(a, b, 'handleDepartmentName'),
      render: (text: string) => renderTableText(text, true),
    },
    {
      title: '提醒公司',
      dataIndex: 'handleCompanyName',
      key: 'handleCompanyName',
      visible: false,
      width: 150,
      isHandle: true,
      sorter: (a: any, b: any) => tableSorter(a, b, 'handleCompanyName'),
      render: (text: string) => renderTableText(text, true),
    },
    //隐藏申请人
    // {
    //   title: '申请人',
    //   dataIndex: 'createrName',
    //   key: 'createrName',
    //   visible: false,
    //   width: 120,
    //   render: (text: string | null) => {
    //     return (
    //       <Tooltip title={tooltipLength(text, 100)}>
    //         <span className={pageStyles['over-flow-hidden']}>{text ? text : '--'}</span>
    //       </Tooltip>
    //     );
    //   },
    // },
    {
      title: '申请岗位',
      dataIndex: 'createPositionName',
      key: 'createPositionName',
      visible: false,
      width: 150,
      render: (text: string | null) => {
        return (
          <Tooltip title={tooltipLength(text, 100)}>
            <span className={pageStyles['over-flow-hidden']}>{text ? text : '--'}</span>
          </Tooltip>
        );
      },
    },
    {
      title: '申请部门',
      dataIndex: 'createDepartmentName',
      key: 'createDepartmentName',
      visible: false,
      width: 150,
      render: (text: string | null) => {
        return (
          <Tooltip title={tooltipLength(text, 100)}>
            <span className={pageStyles['over-flow-hidden']}>{text ? text : '--'}</span>
          </Tooltip>
        );
      },
    },
    {
      title: '申请公司',
      dataIndex: 'createCompanyName',
      key: 'createCompanyName',
      visible: false,
      width: 150,
      render: (text: string | null) => {
        return (
          <Tooltip title={tooltipLength(text, 100)}>
            <span className={pageStyles['over-flow-hidden']}>{text ? text : '--'}</span>
          </Tooltip>
        );
      },
    },
    {
      title: '中标时间',
      dataIndex: 'bidTime',
      key: 'bidTime',
      visible: false,
      width: 150,
      sorter: (a: any, b: any) => (a.ownTime > b.ownTime ? 1 : -1),
      render: (text: string) => {
        const timeStr: string = removeDateHmsStr(text);
        return (
          <>
            <span className={pageStyles['over-flow-hidden']}>{timeStr}</span>
          </>
        );
      },
    },

    {
      title: '申请时间',
      dataIndex: 'ownTime',
      key: 'ownTime',
      visible: false,
      width: 150,
      sorter: (a: any, b: any) => (a.ownTime > b.ownTime ? 1 : -1),
      render: (text: string) => {
        const timeStr: string = removeDateHmsStr(text);
        return (
          <>
            <span className={pageStyles['over-flow-hidden']}>{timeStr}</span>
          </>
        );
      },
    },
    {
      title: '申请人',
      dataIndex: 'ownerName',
      key: 'ownerName',
      visible: false,
      width: 120,
      render: (text: string | null) => {
        return (
          <Tooltip title={tooltipLength(text, 100)}>
            <span className={pageStyles['over-flow-hidden']}>{text ? text : '--'}</span>
          </Tooltip>
        );
      },
    },
    {
      title: '申请岗位',
      dataIndex: 'ownPositionName',
      key: 'ownPositionName',
      visible: false,
      width: 150,
      render: (text: string | null) => {
        return (
          <Tooltip title={tooltipLength(text, 100)}>
            <span className={pageStyles['over-flow-hidden']}>{text ? text : '--'}</span>
          </Tooltip>
        );
      },
    },

    {
      title: '作废类型',
      dataIndex: 'cancelTypeName',
      key: 'cancelTypeName',
      visible: false,
      width: 120,
      sorter: (a: any, b: any) => (a?.cancelType > b?.cancelType ? 1 : -1),
      render: (text: string | null) => {
        return (
          <Fragment>
            <span className={pageStyles['over-flow-hidden']}>{getColorTextLoadMapDom(text)}</span>
          </Fragment>
        );
      },
    },

    {
      title: '作废时间',
      dataIndex: 'cancelTime',
      key: 'cancelTime',
      visible: false,
      width: 150,
      sorter: (a: any, b: any) => (a?.cancelTime > b?.cancelTime ? 1 : -1),
      render: (text: string | null) => {
        return (
          <Fragment>
            <span className={pageStyles['over-flow-hidden']}>{text ? text : '--'}</span>
          </Fragment>
        );
      },
    },
    {
      title: '作废人',
      dataIndex: 'cancelerName',
      key: 'cancelerName',
      visible: false,
      width: 120,
      sorter: (a: any, b: any) => (a?.cancelerID > b?.cancelerID ? 1 : -1),
      render: (text: string | null) => {
        return (
          <Tooltip title={tooltipLength(text, 100)}>
            <span className={pageStyles['over-flow-hidden']}>{text ? text : '--'}</span>
          </Tooltip>
        );
      },
    },
    {
      title: '作废岗位',
      dataIndex: 'cancelPositionName',
      key: 'cancelPositionName',
      visible: false,
      width: 150,
      sorter: (a: any, b: any) => (a?.cancelPositionID > b?.cancelPositionID ? 1 : -1),
      render: (text: string | null) => {
        return (
          <Tooltip title={tooltipLength(text, 100)}>
            <span className={pageStyles['over-flow-hidden']}>{text ? text : '--'}</span>
          </Tooltip>
        );
      },
    },
    {
      title: '作废部门',
      dataIndex: 'cancelDepartmentName',
      key: 'cancelDepartmentName',
      visible: false,
      width: 150,
      sorter: (a: any, b: any) => (a?.cancelDepartmentID > b?.cancelDepartmentID ? 1 : -1),
      render: (text: string | null) => {
        return (
          <Tooltip title={tooltipLength(text, 100)}>
            <span className={pageStyles['over-flow-hidden']}>{text ? text : '--'}</span>
          </Tooltip>
        );
      },
    },
    {
      title: '作废公司',
      dataIndex: 'cancelCompanyName',
      key: 'cancelCompanyName',
      visible: false,
      width: 150,
      sorter: (a: any, b: any) => (a?.cancelCompanyID > b?.cancelCompanyID ? 1 : -1),
      render: (text: string | null) => {
        return (
          <Tooltip title={tooltipLength(text, 100)}>
            <span className={pageStyles['over-flow-hidden']}>{text ? text : '--'}</span>
          </Tooltip>
        );
      },
    },
  ];

  // 非提醒进入不用展示提醒数据
  if (!pageParams?.oversightBtnDom) {
    tableConfig = tableConfig?.filter((item: any) => !item?.isHandle);
  }

  // 合同审核进入
  if (!pageParams?.checkStateColumns) {
    tableConfig = tableConfig?.filter((item: any) => !item?.isShowCheckState);
  }

  if (!(pageParams && (pageParams?.exportBtnDom || pageParams?.oversightBtnDom))) {
    tableConfig?.push({
      title: '操作',
      dataIndex: 'operation',
      key: 'operation',
      width: 220,
      visible: true,
      unDrag: true,
      fixed: 'right',
      render: (_text: any, record: any) => {
        return (
          <div
            style={{
              display: 'flex',
            }}
          >
            {Operation(curRes, clickFnc, record)}
          </div>
        );
      },
    });
  }
  return tableConfig;
};

export { getTableColumns };
